# Get the machine type and kernel name. Piping the output of uname
# # through (tr '[A-Z]' '[a-z]') converts the string to lower case


ARCH := $(shell (uname -m | tr '[A-Z]' '[a-z]'))
OS := $(shell (uname -s | tr '[A-Z]' '[a-z]'))
ARCHOS := $(ARCH)_$(OS)

EXEFILE=meshpar1
BASEDIR := $(HOME)


CC = mpicc 
CFLAGS = -g -Wall 
DEFINES = -DDEBUG -DDEBUG2


DEPS := mstk/ghost-mpi-mstk

INCDIR   := $(addsuffix /include,$(addprefix -I$(BASEDIR)/,$(DEPS))) -I/usr/local/openmpi-1.3.2-intel/include/

LIBDIR := $(addsuffix /lib/$(ARCHOS),$(addprefix -L$(BASEDIR)/,$(DEPS))) -L$(HOME)/mstk/metis-4.0/ \
-L/usr/local/openmpi-1.3.2-intel/lib


LIBS := $(LIBDIR) -lmstk-d 

OTHERLIBS := -lm -lmetis -lmpi -shared-intel
srcs  := $(wildcard *.c)
objs  := $(srcs:.c=.o)
exes  := $(srcs:.c=)



all : ${exes}

$(exes):$(objs)
	$(CC) $(LDFLAGS) $(INCDIR) ${@:=.o} $(LIBS) $(OTHERLIBS)  -o $@




%.o:%.c
	$(CC) $(DEFINES) $(INCDIR) $(CFLAGS) -c $< -o $@



clean :
	/bin/rm -rf ${objs} ${exes} 



